export default {
  props: {

  },
  data () {
    return {
      dictionaries: { // 字典数据
        sale_status: [], // 状态
        goods_type: [], // 商品类型
        after_sale_status: [] // 售后订单状态
      },
      parArray: [] // 按钮权限
    }
  },
  computed: {

  },
  created () {
    // 获取字典值
    for (const type in this.dictionaries) { this.getDictionaries(type) }
  },
  methods: {
    // 获取字典数据
    getDictionaries (type) {
      if (type && this.dictionaries[type].length > 0) { return }
      const params = { groupId: type }
      this.$api.dictionaries(params).then((res) => {
        this.dictionaries[type] = res.data
      }).catch((err) => {
        console.log(err)
      })
    },
    getButtonTreeDto () {
      // 获取权限设定
      this.limits = JSON.parse(sessionStorage.getItem('limit'))
      const params = this.limits.buttonTreeDto.filter((item) => item.menuCode === 'companyCode')
      params[0].buttonList.forEach((item) => { this.parArray.push(item.code) })
      // console.log(this.parArray)
    },
    // 重置表单
    resetForm (formName) { this.$refs[formName].resetFields() },
    // 页面跳转
    toOtherPages (name, parameter, type) {
      let query = { id: parameter, type }
      if (type === 'category') { query = { category: parameter, type } }
      this.$router.push({ name, query })
    }
  }
}
